package com.ars.website;

import com.ars.listStatistics.WebsiteResultsStatistics;
import com.ars.main.User;
import com.ars.other.LogOff;
import com.ars.personalInfomation.UpdateName;
import com.ars.personalInfomation.UpdatePassword;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;

import java.io.IOException;

public class WebsiteMainPaneController {

    @FXML
    public AnchorPane mainPane;

    //1.订单管理
    @FXML
    public void showOrderInformation() {
        Parent root = null;
        try {
            root = FXMLLoader.load(getClass().getResource("../order/Query.fxml"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        mainPane.getChildren().clear();
        mainPane.getChildren().add(root);
    }

    @FXML
    public void refundTicket() {
        Parent root = null;
        try {
            root = FXMLLoader.load(getClass().getResource("../order/TicketRefund.fxml"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        mainPane.getChildren().clear();
        mainPane.getChildren().add(root);
    }

    // 2.业务统计
    @FXML
    public void showWebsteList() {
        Parent root = null;
        try {
            root = FXMLLoader.load(getClass().getResource("../listStatistics/ShowWebsiteList.fxml"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        mainPane.getChildren().clear();
        mainPane.getChildren().add(root);
    }

    @FXML
    public void salesStatistics() {

        VBox LineChartPane = new VBox();
        LineChartPane.setMinWidth(750);
        LineChartPane.getChildren().add(new WebsiteResultsStatistics().getLineChart(User.getName()));
        mainPane.getChildren().clear();
        mainPane.getChildren().add(LineChartPane);
    }

    //3.个人信息管理
    @FXML
    public void updateUserName() {
        new UpdateName().show();
    }

    @FXML
    public void updateUserPassword() {
        new UpdatePassword().show();
    }

    // 4.其他
    @FXML
    public void exitSystem() {
        new LogOff().Show();
    }

}
